from dotenv import load_dotenv, find_dotenv
_ = load_dotenv(find_dotenv())

from openai import OpenAI
client = OpenAI()

# Round 1
messages = [{"role": "user", "content": "9.11 和 9.8哪个大?"}]
response = client.chat.completions.create(
    model="deepseek-reasoner",
    messages=messages,
    stream=True
)

reasoning_content = ""
content = ""

for chunk in response:
    if chunk.choices[0].delta.reasoning_content:
        if reasoning_content == "":
            print("【开始输出思维链】" + "\033[97m" )
        print(chunk.choices[0].delta.reasoning_content, end="")
        reasoning_content += chunk.choices[0].delta.reasoning_content
    elif chunk.choices[0].delta.content:
        if content == "":
            print("\033[0m" + "\n【开始输出结论】")
        print(chunk.choices[0].delta.content, end="")
        content += chunk.choices[0].delta.content

print(f"\n【最终结果】\n{content}")